package com.example.test.advice.第六章_枚举和注解.建议88_用枚举实现工厂方法模式更简洁;

import org.fusesource.mqtt.codec.PUBACK;

public enum CarEnumFactory {

    //定义工厂类，能生产汽车的类型
    FordCar,BuickCar;

    public Car create(){
        switch (this){
            case FordCar:
                return new FordCar();
            case BuickCar:
                return new BuickCar();
            default:
                throw new AssertionError("无匹配的类型");
        }
    }

}
